/*
 * ComponentType.java
 *
 * Created on August 31, 2006, 5:05 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.smallx.xproc;

import com.smallx.xproc.ParameterDefinition;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.infoset.xml.Name;

/**
 *
 * @author alex
 */
public class ComponentType {

   Name name;
   boolean arbitraryInputs;
   boolean arbitraryOutputs;
   Map<Name,PortDefinition> inputs;
   Map<Name,PortDefinition> outputs;
   Map<Name,ParameterDefinition> parameters;
   
   /** Creates a new instance of ComponentType */
   public ComponentType(Name name) {
      this.name = name;
      inputs = new HashMap<Name,PortDefinition>();
      outputs = new HashMap<Name,PortDefinition>();
      parameters = new HashMap<Name,ParameterDefinition>();
      arbitraryInputs = false;
   }
   
   public Name getName() {
      return name;
   }
   
   public void setArbitraryInputs(boolean flag) {
      this.arbitraryInputs = flag;
   }
   
   public boolean hasArbitraryInputs() {
      return arbitraryInputs;
   }

   public void setArbitraryOutputs(boolean flag) {
      this.arbitraryOutputs = flag;
   }
   
   public boolean hasArbitraryOutputs() {
      return arbitraryOutputs;
   }

   public Set<Name> getInputPortNames() {
      return inputs.keySet();
   }
   
   public Set<Name> getOutputPortNames() {
      return outputs.keySet();
   }
   
   public PortDefinition getInputPort(Name name) {
      return inputs.get(name);
   }
   
   public PortDefinition getOutputPort(Name name) {
      return outputs.get(name);
   }
   
   public void addInputPort(Name name,boolean allowSequence) {
      PortDefinition portDef = new PortDefinition(name,allowSequence);
      inputs.put(portDef.getName(),portDef);
   }
   
   public void addOutputPort(Name name,boolean allowSequence) {
      PortDefinition portDef = new PortDefinition(name,allowSequence);
      outputs.put(portDef.getName(),portDef);
   }
}
